// pages/category/component/classify/classify.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    

  },

  /**
   * 组件的初始数据
   */
  data: {
    classifyList: [{
        id: 1,
        name: "人气Top"
      },
      {
        id: 2,
        name: "今日特价"
      },
      {
        id: 3,
        name: "星穹铁道"
      },
      {
        id: 4,
        name: "当季新品"
      },
      {
        id: 5,
        name: "原产地节"
      },
      {
        id: 6,
        name: "瑞幸早餐"
      },
      {
        id: 7,
        name: "果蔬茶"
      },
      {
        id: 8,
        name: "风味拿铁"
      },
      {
        id: 9,
        name: "果c美式"
      },
      {
        id: 10,
        name: "生椰家族"
      }
    ],
    menuKey: 0,
    cartStyle:"",
    cartActive:false

  },
  attached() {
    const {
      classifyList
    } = this.data;
    if (classifyList.length > 0) {
      const selectKey = classifyList[0].id
      this.setData({
        menuKey: selectKey
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onClickMenuItem(e) {
      const id = e.target.dataset.id
      console.log("点击", e)
      console.log("点击菜单id:", id)
      this.setData({
        menuKey: id
      })
    },
    expandCart(e) {
      console.log("展开购物车操作")
      this.setData({
        // cartStyle:"width:300rpx"
        cartActive:!this.data.cartActive
        })
    }
  }
})